IF EXISTS( SELECT * FROM sysobjects WHERE name = 'InstructionReceiverView' AND xtype = 'V' )
BEGIN
	DROP VIEW InstructionReceiverView
END
GO

CREATE VIEW InstructionReceiverView 
AS
SELECT Instruction.*, InstructionReceiver.ReceiverID AS ReceiverID
FROM Instruction
LEFT JOIN InstructionReceiver ON Instruction.InstructionID = InstructionReceiver.InstructionID

GO

IF EXISTS( SELECT * FROM sysobjects WHERE name = 'EmergencyReceiverView' AND xtype = 'V' )
BEGIN
	DROP VIEW EmergencyReceiverView
END
GO

CREATE VIEW EmergencyReceiverView 
AS
SELECT [Emergency].*, EmergencyReceiver.ReceiverID AS ReceiverID, Organization.OrganizationName AS OrganizationName
FROM [Emergency]
INNER JOIN Organization ON [Emergency].OrganizationID = Organization.OrganizationID
LEFT JOIN EmergencyReceiver ON [Emergency].EmergencyID = EmergencyReceiver.EmergencyID
GO
